﻿using AutoMapper;
using BPMN.Application.Contracts.DTO.Response.Permission;
using BPMN.Application.Contracts.DTO.Response;
using BPMN.Application.IService;
using BPMN.Application.Service;
using BPMN.Domain.Entity.User;
using BPMN.DomianShare;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using BPMN.Application.Contracts.DTO.Request.Menu.Permission;

namespace BPMN.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PermissionController : ControllerBase
    {
        private readonly IPermissionAppService AppPermission;

        public PermissionController(IPermissionAppService AppPermission)
        {
            this.AppPermission = AppPermission;
        }

        /// <summary>
        ///  权限添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> AddPermission(PermissionRequstDto entity)
        {
            return Ok(await AppPermission.AddPermission(entity));
        }
        /// <summary>
        /// 权限显示功能
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetPermission()
        {
            return Ok(await AppPermission.GetPermission());
        }
        /// <summary>
        /// 根据Id获取权限信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetPermissionById(int Id)
        {
            return Ok(await AppPermission.GetPermissionById(Id));

        }
        /// <summary>
        /// 修改功能
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IActionResult> UpdatePermission(PermissionRequstDto entity)
        {
            return Ok(await AppPermission.UpdatePermission(entity));
        }
        /// <summary>
        /// 删除功能
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> PermissionDel(int Id)
        {
            return Ok(await AppPermission.DelPer(Id));
        }
        /// <summary>
        /// 获取最高级菜单
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetPermissionMax()
        {
            return Ok(await AppPermission.GetPermissionMax());//qq
        }





       
    }
}
